package ch.unisi.inf.editor;

import java.awt.Color;
import ch.unisi.inf.engine.Image;
/**
 * rotates cyclically the RGB value: RGB -> GBR -> BRG
 * 
 * @author  matthias.eberli@lu.unisi.ch
 */
public class RotateColorsFilter extends Filter
{
    public RotateColorsFilter(final String name)
    {
        super(name);
    }
    
    public void apply(final Image image)
    {
        {
            final int height = image.getHeight();
            final int width = image.getWidth();
            for(int y = 0; y < height; y++) {
                for(int x = 0; x < width; x++) {
                    Color pixel = image.getPixel(x,y);
                    image.setPixel(x, y, new Color(pixel.getGreen(), pixel.getBlue(), pixel.getRed()));
                }
            }
        }   
    } 
}
